<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>防抖</title>
</head>

<body>
  <button id="button">点击按钮</button>
  <script>
    const button = document.querySelector('button');

    function Click() {
      console.log('已点击')
      console.log(this);
    }

    function debounce(func, delay) {
      let timer;
      return function () {
        let context = this;
        clearTimeout(timer);
        timer = setTimeout(function () {
          func.apply(context, arguments);
        }, delay)
      }
    }
    button.addEventListener('click', debounce(Click, 1000));
  </script>
</body>

</html>